<template>
  <div>
    <div v-if="userRole === 'admin'">
      <data-show></data-show>
    </div>
    <div v-if="userRole === 'user'">
      <pet-preview></pet-preview>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import PetPreview from "@/views/customer/petPreview"
import DataShow from "@/views/staff/dataShow"
export default {
  name: "home",
  components: {
    PetPreview,
    DataShow
  },
  data() {
    return {
      userRole: ''
    }
  },
  computed: {
    ...mapState({
      roles: state => state.user.roles
    })
  },
  mounted() {
    // 首页切换
    setTimeout(() => {
      this.getMenu()
    }, 100)
  },
  methods: {
    getMenu() {
      const loginRole = localStorage.getItem('loginRole')
      if(loginRole === 'admin') {
        this.userRole = 'admin'
      } else if(loginRole === 'user') {
        this.userRole = 'user'
      }
    }
  }
}
</script>

<style scoped>

</style>
